let timer = null
self.addEventListener('message', (event) => {
  const data = event.data;
  switch (data.time) {
    case 'start':
      let time = 0;
      timer = setInterval(function() {
        // 向前端页面发送信息
        self.postMessage(time);
        time++;
      }, 2000)
      break;
    case 'end':
      clearInterval(timer)
      break;
  }
}, false)
